package com.sunwayworld.basemodule.samplemanage.location.resource.impl;

import com.sunwayworld.basemodule.samplemanage.location.bean.LimsLocationBoardBean;
import com.sunwayworld.basemodule.samplemanage.location.bean.LimsLocationBoardHoleBean;
import com.sunwayworld.basemodule.samplemanage.location.service.LimsLocationBoardHoleService;
import com.sunwayworld.basemodule.samplemanage.location.validators.LimsLocationBoardDeleteValidator;
import com.sunwayworld.framework.database.sql.Order;
import com.sunwayworld.framework.mybatis.mapper.MatchPattern;
import com.sunwayworld.framework.mybatis.mapper.SearchFilter;
import com.sunwayworld.framework.validator.data.annotation.ValidateDataWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.sunwayworld.basemodule.samplemanage.location.resource.LimsLocationBoardResource;
import com.sunwayworld.basemodule.samplemanage.location.service.LimsLocationBoardService;
import com.sunwayworld.framework.spring.annotation.GikamBean;
import com.sunwayworld.framework.log.annotation.Log;
import com.sunwayworld.framework.log.annotation.LogModule;
import com.sunwayworld.framework.log.annotation.LogType;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;

import java.util.List;

@LogModule("板管理")
@RestController
@GikamBean
public class LimsLocationBoardResourceImpl implements LimsLocationBoardResource {

    @Autowired
    private LimsLocationBoardService limsLocationBoardService;

    @Autowired
    private LimsLocationBoardHoleService locationBoardHoleService;

    @Override
    public LimsLocationBoardService getService() {
        return limsLocationBoardService;
    }

    @Log(value = "新增板管理", type = LogType.INSERT)
    @Override
    @RequestMapping(method = RequestMethod.POST)
    public Long insert(RestJsonWrapperBean wrapper) {
        return getService().insert(wrapper);
    }

    @Override
    @ValidateDataWith(LimsLocationBoardDeleteValidator.class)
    public void delete(RestJsonWrapperBean wrapper) {
        getService().delete(wrapper);
    }

    @Override
    public String updateSampleLocations(RestJsonWrapperBean wrapper) {
        return getService().updateSampleLocations(wrapper);
    }

    @Override
    public void updateSampleBoardHole(RestJsonWrapperBean wrapper) {
        getService().updateSampleBoardHole(wrapper);
    }

    @Override
    public void clearSampleHole(RestJsonWrapperBean wrapper) {
        getService().clearSampleHole(wrapper);
    }

    @Override
    public List<LimsLocationBoardBean> selectBoardList(LimsLocationBoardBean locationBoardBean) {
        return getService().selectBoardList(locationBoardBean);
    }

    @Override
    public List<LimsLocationBoardHoleBean> selectSampleInfoList(LimsLocationBoardHoleBean locationBoardHoleBean) {
        return locationBoardHoleService.selectListByFilter(SearchFilter.instance().match("boardId", locationBoardHoleBean.getBoardId()).filter(MatchPattern.EQ), Order.asc("Y"),Order.asc("X"));
    }

    @Override
    public void kshAssignLocation(RestJsonWrapperBean wrapper) {
        getService().kshAssignLocation(wrapper);
    }

    @Override
    public void rightClickEvent(RestJsonWrapperBean wrapper) {
        getService().rightClickEvent(wrapper);
    }
}
